package com.emar.spring.controller;

import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * 用于页面跳转的类
 */
@Controller
public class HomeController {
	
	private static final Log log = LogFactory.getLog(HomeController.class);
	
	/**
	 * 定位在登录页面
	 * @param locale
	 * @param model
	 * @return
	 */
	@RequestMapping(value = "/", method = RequestMethod.GET)
	public String home(Locale locale, Model model) {
		return "login";
	}
	
	/**
	 * 注销页面
	 * @param locale
	 * @param model
	 * @return
	 */
	@RequestMapping(value = "/logout", method = RequestMethod.GET)
	public String logout(Locale locale, Model model) {
		return "logout";
	}
	
	/**
	 * 用户注册页面
	 * @param locale
	 * @param model
	 * @return
	 */
	@RequestMapping(value = "/register", method = RequestMethod.GET)
	public String register(Locale locale, Model model) {
		return "register";
	}
	
	/**
	 * 管理员管理用户页面
	 * @param locale
	 * @param model
	 * @return
	 */
	@RequestMapping(value = "/adminget", method = RequestMethod.GET)
	public String adminget(Locale locale, Model model) {
		return "admin/userlist";
	}
	
	/**
	 * 跳转到任务或者叫项目页，内含查看图表功能
	 * @param locale
	 * @param model
	 * @return
	 */
	@RequestMapping(value = "/adminpie", method = RequestMethod.GET)
	public String adminpie(Locale locale, Model model) {
		model.addAttribute( "chart",  "pie");
		return "project/projectlist";
	}
	
	/**
	 * 跳转到实际记录页面，内含查看记录统计图表功能
	 * @param locale
	 * @param model
	 * @return
	 */
	@RequestMapping(value = "/recordpie", method = RequestMethod.GET)
	public String recordpie(Locale locale, Model model) {
		model.addAttribute( "chart",  "pie");
		return "record/recordlist";
	}
	
	/**
	 * 跳转到实际记录页面，内含查看记录统计图表功能
	 * @param locale
	 * @param model
	 * @return
	 */
	@RequestMapping(value = "/systempie", method = RequestMethod.GET)
	public String systempie(Locale locale, Model model) {
		model.addAttribute( "chart",  "pie");
		return "system/systemlist";
	}
	@RequestMapping(value = "/singlesystempie", method = RequestMethod.GET)
	public String singlesystempie(Locale locale, Model model) {
		model.addAttribute( "chart",  "pie");
		return "system/singlesystemlist";
	}
	@RequestMapping(value = "/allsystempie", method = RequestMethod.GET)
	public String allsystempie(Locale locale, Model model) {
		model.addAttribute( "chart",  "pie");
		return "system/allsystemlist";
	}
	@RequestMapping(value = "/equipmentpie", method = RequestMethod.GET)
	public String equipmentpie(Locale locale, Model model) {
		model.addAttribute( "chart",  "pie");
		return "system/equipmentlist";
	}
	
	/**
	 * 跳转到查询项目页面
	 * @param locale
	 * @param model
	 * @return
	 */
	@RequestMapping(value = "/searchlist", method = RequestMethod.GET)
	public String search(Locale locale, Model model) {
		return "searchlist";
	}
}
